﻿using Microsoft.AspNetCore.Mvc;
using PowerHub.MES.Common.Utility;
using PowerHub.MES.DTO.ProcessRoute.DTO;
using PowerHub.MES.DTO.ProcessRoute.QueryDto;
using PowerHub.MES.Entities.ProcessRoute;
using PowerHub.MES.IServices.IProcessRoute;
using PowerHub.MES.ReturnEntity;

namespace PowerHub.MES.Controllers.ProcessRoute
{
    /// <summary>
    ///  工艺路线
    /// </summary>
    [ApiController]
    [Route("Api/MES/ProcessRoute/[controller]/[action]")]
    public class CraftBillController
    {

        private IProcessRoute_CraftBillServices _ProcessRoute_CraftBillServices;

        public CraftBillController(IProcessRoute_CraftBillServices CraftBillServices)
        {
            _ProcessRoute_CraftBillServices = CraftBillServices;
        }

        /// <summary>
        /// 获取 工艺路线列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("获取工艺路线列表")]
        public async Task<OperationPageResult<List<ProcessRoute_CraftBill>>> GetProcessRoute_CraftBillPageListAsync([FromBody] QueryProcessRoute_CraftBillDTO pageQuery)
        {
            return await _ProcessRoute_CraftBillServices.GetProcessRoute_CraftBillPageListAsync(pageQuery);
        }
        
        /// <summary>
        /// 获取工艺路线明细列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("获取工艺路线明细列表")]
        public async Task<OperationPageResult<List<ProcessRoute_CraftBillDetial>>> GetProcessRoute_CraftBillDetialsPageListAsync([FromBody] QueryProcessRoute_CraftBillDTO pageQuery)
        {
            return await _ProcessRoute_CraftBillServices.GetProcessRoute_CraftBillDetialsPageListAsync(pageQuery);
        }


        /// <summary>
        /// 批量删除 工艺路线
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("批量删除 工艺路线")]
        public async Task<OperationResult<object>> DeletionProcessRoute_CraftBillAsync([FromBody] List<string> Query)
        {
            return await _ProcessRoute_CraftBillServices.DeletionProcessRoute_CraftBillAsync(Query);
        }

        /// <summary>
        /// 更新 工艺路线
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription(" 更新 工艺路线")]
        public async Task<OperationResult<object>> UpdateProcessRoute_CraftBillAsync([FromBody] ProcessRoute_CraftBillDTO Query)
        {
            return await _ProcessRoute_CraftBillServices.UpdateProcessRoute_CraftBillAsync(Query);
        }

        /// <summary>
        /// 添加工艺路线
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("添加工艺路线")]
        public async Task<OperationResult<object>> CreateProcessRoute_CraftBillAsync([FromBody] ProcessRoute_CraftBillDTO Query)
        {
            return await _ProcessRoute_CraftBillServices.CreateProcessRoute_CraftBillAsync(Query);
        }


        /// <summary>
        /// 修改明细排序
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        [FunctionDescription("修改明细排序")]
        public async Task<OperationResult<bool>> UpdateProcessRoute_CraftBillDetialAsync([FromBody] List<ProcessRoute_CraftBillDetial> query)
        {
            return await _ProcessRoute_CraftBillServices.UpdateProcessRoute_CraftBillDetialAsync(query);
        }

        /// <summary>
        /// 删除明细
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        [FunctionDescription("删除明细")]
        public async Task<OperationResult<bool>> DeletionProcessRoute_CraftBillDetialAsync([FromBody] List<string> ids)
        {
            return await _ProcessRoute_CraftBillServices.DeletionProcessRoute_CraftBillDetialAsync(ids);
        }
    }
}
